<!DOCTYPE html>
<html>
<head>
    <title>Physics Diagram - Wave Reflection</title>
</head>
<body>
<canvas id="canvas" width="550" height="300" style="border:1px solid #eee"></canvas>
<script>
    const canvas = document.getElementById('canvas');
    const ctx = canvas.getContext('2d');

    // --- Style & Configuration ---
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';

    // --- Coordinates & Dimensions ---
    const wallX = 100;
    const originO_X = 400;
    const axisY = 200;
    const axisEndX = 500;
    const dimLineY = 120; // Y-position for the dimension line

    // --- 1. Draw the Wall ---
    ctx.beginPath();
    ctx.moveTo(wallX, axisY - 70);
    ctx.lineTo(wallX, axisY + 70);
    ctx.stroke();

    // Draw wall hatching
    ctx.save();
    ctx.lineWidth = 1.5;
    for (let y = axisY - 65; y <= axisY + 55; y += 15) {
        ctx.beginPath();
        ctx.moveTo(wallX, y);
        ctx.lineTo(wallX - 10, y + 10);
        ctx.stroke();
    }
    ctx.restore();

    // --- 2. Draw the X-Axis ---
    ctx.beginPath();
    ctx.moveTo(wallX, axisY);
    ctx.lineTo(axisEndX, axisY);
    ctx.stroke();

    // Arrowhead for x-axis
    ctx.beginPath();
    ctx.moveTo(axisEndX, axisY);
    ctx.lineTo(axisEndX - 15, axisY - 6);
    ctx.lineTo(axisEndX - 15, axisY + 6);
    ctx.closePath();
    ctx.fill();

    // 'x' label for the axis
    ctx.font = 'italic 24px Times New Roman';
    ctx.fillText('x', axisEndX + 20, axisY + 5);

    // --- 3. Draw Point O ---
    // The point itself
    ctx.beginPath();
    ctx.arc(originO_X, axisY, 4, 0, 2 * Math.PI);
    ctx.fill();

    // The 'O' label
    ctx.font = '28px Times New Roman';
    ctx.fillText('O', originO_X, axisY + 30);


    // --- 4. Draw the Dimension Line ---
    // The main horizontal line for the dimension
    ctx.beginPath();
    ctx.moveTo(wallX, dimLineY);
    ctx.lineTo(originO_X, dimLineY);
    ctx.stroke();
    
    // Left arrowhead (pointing towards the wall)
    const arrowHeadSize = 15;
    ctx.beginPath();
    ctx.moveTo(wallX, dimLineY); // Tip of the arrow is at the wall's x-coordinate
    ctx.lineTo(wallX + arrowHeadSize, dimLineY - 6);
    ctx.lineTo(wallX + arrowHeadSize, dimLineY + 6);
    ctx.closePath();
    ctx.fill();

    // Right vertical bar at point O's x-coordinate
    ctx.beginPath();
    ctx.moveTo(originO_X, dimLineY - 8);
    ctx.lineTo(originO_X, dimLineY + 8);
    ctx.stroke();

    // --- 5. Draw the Dimension Label (5/4 λ) ---
    const textCenterX = wallX + (originO_X - wallX) / 2;
    const labelY = dimLineY - 35;
    
    ctx.font = '32px Times New Roman';
    
    // Draw '5' (numerator)
    ctx.textBaseline = 'bottom';
    ctx.fillText('5', textCenterX - 8, labelY + 13);
    
    // Draw the fraction bar
    ctx.save();
    ctx.beginPath();
    ctx.lineWidth = 1.5;
    ctx.moveTo(textCenterX - 25, labelY + 15);
    ctx.lineTo(textCenterX + 5, labelY + 15);
    ctx.stroke();
    ctx.restore();

    // Draw '4' (denominator)
    ctx.textBaseline = 'top';
    ctx.fillText('4', textCenterX - 8, labelY + 17);
    
    // Draw 'λ' (lambda)
    ctx.font = 'italic 32px Times New Roman';
    ctx.textBaseline = 'middle';
    ctx.fillText('λ', textCenterX + 35, labelY + 15);

</script>
</body>
</html>